"use strict";
(function($){
var $body=$('body');
var $window=$(window);
function putPlaceholdersToInputs(){
$('select').wrap('');
$('select[name="cat"]').on('change', function(){
var $form=$(this).closest('form');
if($form.length){
$form.trigger('submit');
}});
$('label[for]').each(function (){
var $label=$(this);
var $input=$('#'+ $label.attr('for'));
if(!$input.attr('placeholder')){
if(!$input.is('[type="radio"]')&&!$input.is('[type="checkbox"]')&&!$input.is('select')){
$input.attr('placeholder', $label.text());
$label.css({'display': 'none'});
}}
})
}
function menuHideExtraElements(){
if($body.hasClass('header_show_all_menu_items')&&!$body.find('.header_logo_center').length){
return;
}
$('.sf-more-li, .sf-logo-li').remove();
var windowWidth=$('body').innerWidth();
$('.sf-menu').each(function(){
var $thisMenu=$(this);
var $menuWraper=$thisMenu.closest('.top-nav');
$menuWraper.attr('style', '');
if(windowWidth > 1199){
var $menuLis=$menuWraper.find('.sf-menu > li');
$menuLis.removeClass('sf-xl-hidden');
var $headerLogoCenter=$thisMenu.closest('.header_logo_center');
var logoWidth=0;
var summaryLiWidth=0;
if($headerLogoCenter.length){
var $logo=$headerLogoCenter.find('.logo');
logoWidth=$logo.outerWidth(true) + 70;
}
var wrapperWidth=$menuWraper.outerWidth(true);
$menuLis.each(function(index){
var elementWidth=$(this).outerWidth() +4;
summaryLiWidth +=elementWidth;
if(summaryLiWidth >=(wrapperWidth-logoWidth)){
var $newLi=$('...');
$($menuLis[index - 1 ]).before($newLi);
var newLiWidth=$($newLi).outerWidth(true);
var $extraLiElements=$menuLis.filter(':gt('+(index - 2) +')');
$extraLiElements.clone().appendTo($newLi.find('ul'));
$extraLiElements.addClass('sf-xl-hidden');
return false;
}});
if($headerLogoCenter.length){
var $menuLisVisible=$headerLogoCenter.find('.sf-menu > li:not(.sf-xl-hidden)');
var menuLength=$menuLisVisible.length;
var summaryLiVisibleWidth=0;
$menuLisVisible.each(function(){
summaryLiVisibleWidth +=$(this).outerWidth();
});
var centerLi=Math.floor(menuLength / 2);
if((menuLength % 2===0)){
centerLi--;
}
var $liLeftFromLogo=$menuLisVisible.eq(centerLi);
$liLeftFromLogo.after(' ');
$headerLogoCenter.find('.sf-logo-li').width(logoWidth);
var liLeftRightDotX=$liLeftFromLogo.offset().left + $liLeftFromLogo.outerWidth();
var logoLeftDotX=windowWidth/2 - logoWidth/2;
var menuLeftOffset=liLeftRightDotX - logoLeftDotX;
$menuWraper.css({'left': -menuLeftOffset})
}}
});
}
function initMegaMenu(timeOut){
var $megaMenu=$('.top-nav .mega-menu');
if($megaMenu.length){
setTimeout(function (){
var windowWidth=$('body').innerWidth();
if(windowWidth > 991){
$megaMenu.each(function(){
var $thisMegaMenu=$(this);
$thisMegaMenu.css({'display': 'block', 'left': 'auto'});
var stickedSideHeaderWidth=0;
var $stickedSideHeader=$('.header_side_sticked');
if($stickedSideHeader.length&&$stickedSideHeader.hasClass('active-slide-side-header')){
stickedSideHeaderWidth=$stickedSideHeader.outerWidth(true);
if($stickedSideHeader.hasClass('header_side_right')){
stickedSideHeaderWidth=-stickedSideHeaderWidth;
}
windowWidth=windowWidth - stickedSideHeaderWidth;
}
var thisWidth=$thisMegaMenu.outerWidth();
var thisOffset=$thisMegaMenu.offset().left - stickedSideHeaderWidth;
var thisLeft=(thisOffset + (thisWidth/2)) - windowWidth/2;
$thisMegaMenu.css({'left':-thisLeft, 'display': 'none'});
if(!$thisMegaMenu.closest('ul').hasClass('nav')){
$thisMegaMenu.css('left', '');
}});
}}, timeOut);
}}
function initAffixSidebar(){
var $affixAside=$('.affix-aside');
if($affixAside.length){
$window=$(window);
$affixAside.on('affix.bs.affix', function(e){
var affixWidth=$affixAside.width() - 1;
var affixLeft=$affixAside.offset().left;
$affixAside
.width(affixWidth)
.css("left", affixLeft);
}).on('affix-bottom.bs.affix', function(e){
var affixWidth=$affixAside.width() - 1;
var stickedSideHeaderWidth=0;
var $stickedSideHeader=$('.header_side_sticked');
if($stickedSideHeader.length&&$stickedSideHeader.hasClass('active-slide-side-header')&&!$stickedSideHeader.hasClass('header_side_right')){
stickedSideHeaderWidth=$stickedSideHeader.outerWidth(true);
}
var affixLeft=$affixAside.offset().left - stickedSideHeaderWidth - $('#box_wrapper').offset().left;;
$affixAside
.width(affixWidth)
.css("left", affixLeft);
}).on('affix-top.bs.affix', function(e){
$affixAside.css({"width": "", "left": ""});
});
var offsetTopAdd=10;
var offsetBottomAdd=150;
var offsetTop=$affixAside.offset().top - $('.page_header').height();
var offsetBottom=$('.page_footer').outerHeight(true) + $('.page_copyright').outerHeight(true);
$affixAside.affix({
offset: {
top: offsetTop - offsetTopAdd,
bottom: offsetBottom + offsetBottomAdd
},
});
$window.on('resize', function(){
$affixAside.removeClass("affix affix-bottom").addClass("affix-top").trigger('affix-top.bs.affix');
var offsetTopSectionsArray=[
'.page_topline',
'.page_toplogo',
'.page_header',
'.page_title',
'.blog_slider',
'.blog-featured-posts'
];
var offsetTop=0;
offsetTopSectionsArray.map(function (val){
offsetTop +=$(val).outerHeight(true)||0;
});
var offsetBottom=$('.page_footer').outerHeight(true)
+ $('.page_copyright').outerHeight(true);
$affixAside.data('bs.affix').options.offset.top=offsetTop - offsetTopAdd;
$affixAside.data('bs.affix').options.offset.bottom=offsetBottom + offsetBottomAdd;
$affixAside.affix('checkPosition');
});
$affixAside.affix('checkPosition');
}}
function initPhotoSwipe(){
if(typeof PhotoSwipe!=='undefined'){
var gallerySelectors='.photoswipe-link, a[data-gal^="prettyPhoto"], [data-thumb] a';
var $galleryLinks=$(gallerySelectors);
if($galleryLinks.length){
if(!($('.pswp').length)){
$body.append('');
}else{
return;
}
$('body').on('click', gallerySelectors, function (e){
e.preventDefault();
var $link=$(this);
var $linksParentContainer=$link.closest('.photoswipe-container, .isotope-wrapper, .owl-carousel, .flickr_ul, .images');
var $links=$linksParentContainer.find(gallerySelectors);
if(!$links.length){
$links.push($link);
}
var items=[];
var options={
bgOpacity:0.7,
showHideOpacity:true,
history: false,
shareEl: false,
index: 0
};
var gallery=$('.pswp')[0];
var counter=0;
var clonedClick=false;
var clonedRealIndex=0;
$links.each(function (i){
var $this=$(this);
if($this.closest('.clone, .cloned').length){
if(($link[0]===$this[0])){
clonedClick=true;
clonedRealIndex=parseInt($this.data('index'), 10);
options.index=clonedRealIndex;
}
return;
}
var item={};
if(($link[0]===$this[0])){
options.index=counter;
}
if($this.data('iframe')){
var autoplay=($links.length > 1) ? '':'&autoplay=1';
item.html='';
if($this.data('iframe').indexOf('src=')!==-1){
item.html +=$this.data('iframe').replace(/&/g, '&').replace(/$lt;/g, '<').replace(/>/g, '>').replace(/$quot;/g, '"');
}else{
item.html +='';
}
item.html +='
';
}else{
item.src=$this.attr('href');
var width=1200;
var height=675;
var data=$this.data();
var dataImage=$this.find('img').first().data();
if(data.width){
width=data.width;
}
if(data.height){
height=data.height;
}
if(typeof dataImage!=='undefined'){
if(dataImage.large_image_width){
width=dataImage.large_image_width;
}
if(dataImage.large_image_height){
height=dataImage.large_image_height;
}}
item.w=width;
item.h=height;
}
items.push(item);
counter++;
});
var pswpGallery=new PhotoSwipe(gallery, PhotoSwipeUI_Default, items, options);
pswpGallery.init();
pswpGallery.listen('afterChange', function(){
$(pswpGallery.container).find('iframe').each(function(){
$(this)[0].contentWindow.postMessage('{"method":"pause","event":"command","func":"pauseVideo","args":""}', '*')
});
});
pswpGallery.listen('close', function(){
$(pswpGallery.container).find('iframe').each(function(){
$(this)[0].contentWindow.postMessage('{"method":"pause","event":"command","func":"pauseVideo","args":""}', '*')
});
});
});
}}
}
function initAnimateElement(self, index){
var animationClass = !self.data('animation') ? 'fadeInUp':self.data('animation');
var animationDelay = !self.data('delay') ? 150:self.data('delay');
setTimeout(function(){
self.addClass("animated " + animationClass);
}, index * animationDelay);
}
function initCounter(self){
if(self.hasClass('counted')){
return;
}else{
self.countTo().addClass('counted');
}}
function initProgressbar(el){
el.progressbar({
transition_delay: 300
});
}
function initChart(el){
var data=el.data();
var size=data.size ? data.size:270;
var line=data.line ? data.line:20;
var bgcolor=data.bgcolor ? data.bgcolor:'#ffffff';
var trackcolor=data.trackcolor ? data.trackcolor:'#c14240';
var speed=data.speed ? data.speed:3000;
el.easyPieChart({
barColor: trackcolor,
trackColor: bgcolor,
scaleColor: false,
scaleLength: false,
lineCap: 'butt',
lineWidth: line,
size: size,
rotate: 0,
animate: speed,
onStep: function(from, to, percent){
$(this.el).find('.percent').text(Math.round(percent));
}});
}
function initGoogleMap(){
var $googleMaps=$('#map, .page_map');
if($googleMaps.length){
$googleMaps.each(function(){
var $map=$(this);
var lat;
var lng;
var map;
var styles=[
{
"featureType": "all",
"elementType": "geometry.fill",
"stylers": [
{
"weight": "2.00"
}
]
},
{
"featureType": "all",
"elementType": "geometry.stroke",
"stylers": [
{
"color": "#9c9c9c"
}
]
},
{
"featureType": "all",
"elementType": "labels.text",
"stylers": [
{
"visibility": "on"
}
]
},
{
"featureType": "landscape",
"elementType": "all",
"stylers": [
{
"color": "#f2f2f2"
}
]
},
{
"featureType": "landscape",
"elementType": "geometry.fill",
"stylers": [
{
"color": "#ffffff"
}
]
},
{
"featureType": "landscape.man_made",
"elementType": "geometry.fill",
"stylers": [
{
"color": "#ffffff"
}
]
},
{
"featureType": "poi",
"elementType": "all",
"stylers": [
{
"visibility": "off"
}
]
},
{
"featureType": "road",
"elementType": "all",
"stylers": [
{
"saturation": -100
},
{
"lightness": 45
}
]
},
{
"featureType": "road",
"elementType": "geometry.fill",
"stylers": [
{
"color": "#eeeeee"
}
]
},
{
"featureType": "road",
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#7b7b7b"
}
]
},
{
"featureType": "road",
"elementType": "labels.text.stroke",
"stylers": [
{
"color": "#ffffff"
}
]
},
{
"featureType": "road.highway",
"elementType": "all",
"stylers": [
{
"visibility": "simplified"
}
]
},
{
"featureType": "road.arterial",
"elementType": "labels.icon",
"stylers": [
{
"visibility": "off"
}
]
},
{
"featureType": "transit",
"elementType": "all",
"stylers": [
{
"visibility": "off"
}
]
},
{
"featureType": "water",
"elementType": "all",
"stylers": [
{
"color": "#46bcec"
},
{
"visibility": "on"
}
]
},
{
"featureType": "water",
"elementType": "geometry.fill",
"stylers": [
{
"color": "#c8d7d4"
}
]
},
{
"featureType": "water",
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#070707"
}
]
},
{
"featureType": "water",
"elementType": "labels.text.stroke",
"stylers": [
{
"color": "#ffffff"
}
]
}
];
var $markers=$map.find('.marker');
var address=$markers.first().find('.marker-address').text() ? $markers.first().find('.marker-address').text():'london, baker street, 221b';
var geocoder=new google.maps.Geocoder();
var draggable=$map.data('draggable') ? $map.data('draggable'):false;
var scrollwheel=$map.data('scrollwheel') ? $map.data('scrollwheel'):false;
geocoder.geocode({
address: address
}, function(data){
lat=data[0].geometry.location.lat();
lng=data[0].geometry.location.lng();
var center=new google.maps.LatLng(lat, lng);
var settings={
mapTypeId: google.maps.MapTypeId.ROADMAP,
zoom: 16,
draggable: draggable,
scrollwheel: scrollwheel,
center: center,
styles: styles
};
map=new google.maps.Map($map[0], settings);
var infoWindows=[];
$($markers).each(function(index){
var $marker=$(this);
var markerTitle=$marker.find('.marker-title').text();
var markerDescription='';
markerDescription +=markerTitle ? '' + markerTitle + '
':'';
markerDescription +=$marker.find('.marker-description').html() ? '' + $marker.find('.marker-description').html() + '
':'';
if(markerDescription){
markerDescription='' + markerDescription + '
';
}
geocoder.geocode({
address: $marker.find('.marker-address').text()
}, function(data){
var iconSrc=$marker.find('.marker-icon').attr('src');
var lat=data[0].geometry.location.lat();
var lng=data[0].geometry.location.lng();
var center=new google.maps.LatLng(lat, lng);
var marker=new google.maps.Marker({
position: center,
title: markerTitle,
map: map,
icon: iconSrc
});
var infowindow=new google.maps.InfoWindow({
content: markerDescription
});
infoWindows.push(infowindow);
google.maps.event.addListener(marker, 'click', function(){
for (var i=0;i');
}}
if($().superfish){
$('ul.sf-menu').superfish({
popUpSelector: 'ul:not(.mega-menu ul), .mega-menu ',
delay: 700,
animation: {opacity:'show', marginTop: 0},
animationOut: {opacity: 'hide', marginTop: 5},
speed: 200,
speedOut: 200,
disableHI: false,
cssArrows: true,
autoArrows: true,
onInit: function (){
var $thisMenu=$(this);
$thisMenu.find('.sf-with-ul').after('